/**
 * @param {string} s
 * @param {character} c
 * @return {number[]}
 */
export var shortestToChar = function (s, c) {
  const ans = []
  let cIndex = -s.length
  for (let i = 0; i < s.length; i++) {
    if (s[i] === c) {
      cIndex = i
    }
    ans[i] = i - cIndex
  }
  cIndex = 2 * s.length
  for (let i = s.length - 1; i >= 0; i--) {
    if (s[i] === c) {
      cIndex = i
    }
    ans[i] = Math.min(ans[i], cIndex - i)
  }
  return ans
}
